# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=airoscript
pkgver=45.0a122ee
pkgrel=11
epoch=2
pkgdesc='A script to simplify the use of aircrack-ng tools.'
arch=('any')
url='http://midnightresearch.com/projects/wicrawl/'
groups=('blackarch' 'blackarch-wireless')
license=('GPL')
depends=('mdk3' 'aircrack-ng' 'dhclient' 'perl-yaml-syck')
options=(!makeflags)
makedepends=('git')
source=("$pkgname::git+http://github.com/patrickhno/Airoscript.git"
        'Makefile.patch')
sha512sums=('SKIP'
            'c7b9eb321243ff436c3bd0887cf11400bedc206c097d6abfc102f4fba4920aa6223b39f978cb64a4c032adb70940c815a4241b7ec4eb017f6b51e0e34fd13bca')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  sed -i 's|/etc/airoscript-ng.conf|/etc/airoscript-ng/airoscript-ng.conf|g' \
    src/airoscript-ng

  patch -Np1 < "$srcdir/Makefile.patch"

  find -type f -exec sed -i 's|/sbin|/bin|g' {} \;
}

package() {
  cd $pkgname

  rm -rf src/locale/*

  make prefix="$pkgdir/usr" aircrack_prefix="/usr" \
    etcdir="$pkgdir/etc/airoscript-ng" install

  sed -i 's|/local||' "$pkgdir"/etc/airoscript-ng/*
  sed -i 's|/minimal.theme|defaul.theme|' "$pkgdir"/etc/airoscript-ng/*
}

